/**
 * 
 */
package com.scaffold.springmvc.action;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.async.DeferredResult;

import com.scaffold.BasicBizAction;
import com.scaffold.commons.web.WebUtil;

/**
 * @author wangjg
 *
 */
@Controller
public class CaptchaAction extends BasicBizAction{

	@ResponseBody
	@RequestMapping("/captchaId.xhtml")
	public String getCaptchaId(){
		return null;
	}
	
	@RequestMapping("/captchaImg.xhtml")
	public void getCaptchaImg(HttpServletResponse response, String captchaId) throws Exception {
		if(!isValidCaptchaId(captchaId)){
			return;
		}
		WebUtil.disableCache(response);
		BufferedImage challenge = null;//
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		
		
		
		ServletOutputStream os = response.getOutputStream();
		bos.writeTo(os);
		os.flush();
		os.close();
	}

	private boolean isValidCaptchaId(String captchaId) {
		return true;
	}
}
